package com.kx.strategy_mode;

/**
 * Created on 2021/10/14.
 *
 * @author KaiXuan Xiao
 */
///////////////////////////////////////////////////////////////////////////
// 返利收费
///////////////////////////////////////////////////////////////////////////
public class CashReturn extends CashSuper {

    // 条件
    private double moneyCondition = 0.0d;
    // 返多少
    private double moneyReturn = 0.0d;

    public CashReturn(String moneyCondition, String moneyReturn){
        this.moneyCondition = Double.parseDouble(moneyCondition);
        this.moneyReturn = Double.parseDouble(moneyReturn);
    }

    @Override
    public double acceptCash(double money) {
        double result = money;
        if (result >= moneyCondition){
            result = money - Math.floor(money / moneyCondition) * moneyReturn;
        }
        return result;
    }

}
